/**
 * @fileoverview Classes for Icodeon SCORM API Adapter
 * @author Icodeon Ltd mailto:sales@icodeon.com
 * @license Apache License 2.0
 * @version 1.0
 */
var icodeon;
if(!icodeon){icodeon = {};}
else if(typeof icodeon != "object"){throw new Error("namepsace icodeon exists");}
if(!icodeon.rte){icodeon.rte = {};}
else if(typeof icodeon.rte != "object"){throw new Error("namepsace icodeon.rte exists");}

/**
 * Construct an Error subclass for Run Time exceptions
 * 
 * @class This class represents an instance of RunTimeError .
 * @extends Error
 * @constructor
 * @return A new instance of RunTimeError
 */	
icodeon.rte.RteError = function(int_ErrorCode, str_Diagnostic){

	/**
	 * Method to call the superclass.
	 */
	Error.call(this, int_ErrorCode + "-" + str_Diagnostic);
	this.message = int_ErrorCode + "-" + str_Diagnostic;
	
	/**
	 * @return A SCORM 2004 error code
	 * @type Number
	 */
	this.getErrorCode = function(){
		return int_ErrorCode;
	}

	this.toString = function(){
		var str_Msg = "Type: icodeon.rte.RteError \n";
		str_Msg += "message: " + this.message + "\n";
		return str_Msg;
	};
};

// rte.RteError properties
icodeon.rte.RteError.prototype = new Error();
icodeon.rte.RteError.prototype.constructor = icodeon.rte.RteError;

/**
 * Config options {cmiName:String, read:Boolean, write:Boolean, cocdName:String}
 * @class The class is a wrapper for SCORM 2004 Run Time Environment definitions
 * @constructor
 * @param {Object} Config element
 */
icodeon.rte.Definition = function (arr_Config) {
	
	// Import namespaces
	this.x = icodeon.xml;
	
    this.field = arr_Config;
    
    /**
     * 
     */
    var arr_Children = new Array();
    
    /**
	 * @private
	 */
	var arr_CmiVocab = new Array();
	arr_CmiVocab["completion_status"] = ["completed","incomplete","not attempted","unknown"];
	arr_CmiVocab["credit"] = ["credit","no-credit"];
	arr_CmiVocab["entry"] = ["ab-initio","resume",""];
	arr_CmiVocab["exit"] = ["time-out","suspend","logout","normal",""];
	arr_CmiVocab["mode"] = ["browse","normal","review"];
	arr_CmiVocab["result"] = ["correct","incorrect","unanticipated","neutral"];
	arr_CmiVocab["success_status"] = ["passed","failed","unknown"];
	arr_CmiVocab["type"] = ["true-false","choice","fill-in","long-fill-in","matching","performance","sequencing","likert","numeric","other"];
	

	/**
	 * @private
	 */
	var vocabValidator = function(str_Name,str_Value){
		var b_Valid = false;
    	for (var i=0; i<arr_CmiVocab[str_Name].length; i++){
    		if (arr_CmiVocab[str_Name][i] == str_Value) {
    			b_Valid = true;
    			break;
    		}
    	}
    	
    	if(!b_Valid){
    		// Data Model Element Type Mismatch (406)
    		throw new icodeon.cocd.CocdError(406, 
    		"Invalid data model value: \'" + str_Value + "\' for element: \'" + str_Name + "\'");
    	}
	};
	
	/**
	 * @private
	 */
	var entryFromXml = function(str_CocdValue){
		 return(str_CocdValue=="ab_initio")?"ab-initio":str_CocdValue;
	};
	
	/**
	 * @private
	 * 
	 * Suspend data sometimes will have illegal XML characters
	 * (such as the output from Articulate Quiz Maker 9), so
	 * we have to encode and decode the character string
	 * to and from XML.
	 */
	var suspendDataFromXml = function(str_CocdValue){
		return this.x.decode(str_CocdValue);
	};
	
	/**
	 * @private
	 */
	var suspendDataToXml = function(str_CocdValue){
		return this.x.encode(str_CocdValue);
	};
	
	this.appendChild = function(obj_Definition){
		arr_Children.push(obj_Definition.field.cmiName);
	};
	
	this.getChildren = function(){
		return arr_Children.join(',');
	};
	
	this.isLeaf = function(){
		if(arr_Children.length == 0){
			return true;
		}
		return false;
	};
	
	/**
	 * Validates a CMI vocabulary token for this definition
 	 * @param {str_CmiValue} CMI element value
 	 * @throws icodeon.cocd.CocdError
	 */
    this.validateCmiValue = function(str_CmiValue){
    	vocabValidator(this.field.cmiName, str_CmiValue);
    };
    
	/**
	 * Translates the COCD vocabulary value to CMI vocabulary
 	 * @param {String} str_CocdValue COCD element value
 	 * @return the CMI element value
 	 * @type String
	 */
    this.toCmiValue = function(str_CocdValue){
    	var str_FunctionName = this.field.cocdName + "FromXml";
    	var fn = undefined;
    	try{
    		fn = eval(str_FunctionName);
    		return fn(str_CocdValue);
    	}
    	catch(obj_Error){
			return str_CocdValue;
    	}
    };
    
	/**
	 * Translates the CMI vocabulary value to COCD vocabulary
 	 * @param {String} str_CmiValue CMI element value
 	 * @return the COCD element value
 	 * @type String
	 */
    this.toCocdValue = function(str_CmiValue){
    	var str_FunctionName = this.field.cocdName + "ToXml";
    	var fn = undefined;
    	try{
    		fn = eval(str_FunctionName);
    		return fn(str_CmiValue);
    	}
    	catch(obj_Error){
			return str_CmiValue;
    	}
    };
    
    this.toString = function(){
    	return this.field.cocdName;
    };
}

/**
 * Base class to be extended to construct a SCORM 1.2
 * or SCORM 2004 Adapter. All parameter argument to the base
 * class, if there are CMI data model elements, are SCORM 2004.
 * A derived class for a SCORM 1.2 adapter will convert 1.2 to
 * 2004 parameter names.
 * @class The class is a base class for SCORM API Adapters
 * @constructor
 * @return A new instance of a SCORM API Adapter base class
 */
icodeon.rte.Adapter = function(){
	
	// Import namespaces
	this.x = icodeon.xml;
	this.c = icodeon.cocd;
	this.r = icodeon.rte;
	
	/**
	 * @private
	 */
	var arr_Config = [];
	this.definitions = new Array();
	
	arr_Config = {cmiName:'_version', read:true, write:false, keyword:true};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'_children', read:true, write:false, keyword:true};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'_count', read:true, write:false, keyword:true};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'comments_from_learner', read:false, write:false, keyword:false, cocdName:'commentsFromLearner'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'comments_from_lms', read:false, write:false, keyword:false, cocdName:'commentsFromLMS'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'completion_status', read:true, write:true, keyword:false, cocdName:'completionStatus'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'completion_threshold', read:true, write:false, keyword:false, cocdName:'completionThreshold'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'credit', read:true, write:false, keyword:false, cocdName:'credit'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'entry', read:true, write:false, keyword:false, cocdName:'entry'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);

	arr_Config = {cmiName:'exit', read:false, write:true, keyword:false, cocdName:'exit'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'interactions', read:false, write:false, keyword:false, cocdName:'interactions'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'launch_data', read:true, write:false, keyword:false, cocdName:'launchData'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'learner_id', read:true, write:false, keyword:false, cocdName:'learnerId'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'learner_name', read:true, write:false, keyword:false, cocdName:'learnerName'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'learner_preference', read:true, write:false, keyword:false, cocdName:'learnerPreferenceData'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'audio_captioning', read:true, write:true, keyword:false, cocdName:'audioCaptioning'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	this.definitions['learner_preference'].appendChild(this.definitions[arr_Config.cmiName]);
	
	arr_Config = {cmiName:'audio_level', read:true, write:true, keyword:false, cocdName:'audioLevel'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	this.definitions['learner_preference'].appendChild(this.definitions[arr_Config.cmiName]);
	
	arr_Config = {cmiName:'delivery_speed', read:true, write:true, keyword:false, cocdName:'deliverySpeed'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	this.definitions['learner_preference'].appendChild(this.definitions[arr_Config.cmiName]);
	
	arr_Config = {cmiName:'language', read:true, write:true, keyword:false, cocdName:'language'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	this.definitions['learner_preference'].appendChild(this.definitions[arr_Config.cmiName]);
	
	arr_Config = {cmiName:'location', read:true, write:true, keyword:false, cocdName:'location'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'max_time_allowed', read:true, write:false, keyword:false, cocdName:'maxTimeAllowed'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);

	arr_Config = {cmiName:'mode', read:true, write:false, keyword:false, cocdName:'mode'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'objectives', read:false, write:false, keyword:false, cocdName:'objectives'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);

	arr_Config = {cmiName:'progress_measure', read:true, write:true, keyword:false, cocdName:'progressMeasure'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'scaled_passing_score', read:true, write:false, keyword:false, cocdName:'scaledPassingScore'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'score', read:false, write:false, keyword:false, cocdName:'score'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'max', read:true, write:true, keyword:false, cocdName:'max'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	this.definitions['score'].appendChild(this.definitions[arr_Config.cmiName]);
	
	arr_Config = {cmiName:'min', read:true, write:true, keyword:false, cocdName:'min'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	this.definitions['score'].appendChild(this.definitions[arr_Config.cmiName]);
	
	arr_Config = {cmiName:'raw', read:true, write:true, keyword:false, cocdName:'raw'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	this.definitions['score'].appendChild(this.definitions[arr_Config.cmiName]);

	arr_Config = {cmiName:'scaled', read:true, write:true, keyword:false, cocdName:'scaled'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	this.definitions['score'].appendChild(this.definitions[arr_Config.cmiName]);

	arr_Config = {cmiName:'session_time', read:false, write:true, keyword:false, cocdName:'sessionTime'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);

	arr_Config = {cmiName:'success_status', read:true, write:true, keyword:false, cocdName:'successStatus'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'suspend_data', read:true, write:true, keyword:false, cocdName:'suspendData'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);

	arr_Config = {cmiName:'time_limit_action', read:true, write:false, keyword:false, cocdName:'timeLimitAction'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);
	
	arr_Config = {cmiName:'total_time', read:true, write:false, keyword:false, cocdName:'totalTime'};
	this.definitions[arr_Config.cmiName] = new this.r.Definition(arr_Config);


	// the Content Object Communication Data Model
	this.obj_Cocd = undefined;
	
	/**
	 * @final
	 */
	this.TRUE = "true";
	/**
	 * @final
	 */
	this.FALSE = "false";
	/**
	 * @final
	 */
	this.EMPTY_STR = "";
	/**
	 * @private
	 */
	this.int_ErrorCode = 0;
	/**
	 * @private
	 */
	this.str_ErrorDiagnostic = undefined;
	/**
	 * @private
	 */
	this.b_Initalized = false;
	/**
	 * @private
	 */
	this.b_Terminated = false;
	/**
	 * @private
	 */
	this.errors = new Array();
	
	/**
	 * @param {Object} obj_Expected
	 * @param {Object} obj_Tested
	 * @throws icodeon.rte.RteError for invalid data type or value
	 */
	this.assertEquals = function(obj_Expected, obj_Tested){
		if(typeof(obj_Expected) != typeof(obj_Tested)){
			throw new icodeon.rte.RteError("Invalid data type: " + typeof(obj_Tested));
		}
		if(obj_Expected != obj_Tested){
			throw new icodeon.rte.RteError("Invalid data value: " + obj_Tested);
		}
	};
	
	/**
	 * @param {Object} obj_Tested
	 * @throws icodeon.rte.RteError for null or undefined
	 */
	this.assertNotNullOrUndefined = function(obj_Tested){
		if(typeof(obj_Tested) == "undefined"){
			throw new icodeon.rte.RteError("Object is not defined: " + typeof(obj_Tested));
		}
		if(obj_Tested == null){
			throw new icodeon.rte.RteError("Object is null: " + obj_Tested);
		}
	};
	
	/**
	 * @param {Object} obj_Tested
	 * @throws icodeon.rte.RteError for not a string
	 */
	this.assertString = function(obj_Tested){
		if(typeof(obj_Tested) != "string"){
			throw new icodeon.rte.RteError("Object is not a string data type: " + typeof(obj_Tested));
		}
		if(obj_Tested == null){
			throw new icodeon.rte.RteError("String is null: " + obj_Tested);
		}
	};
	
	/**
	 * @param {Object} obj_Tested
	 * @throws icodeon.rte.RteError for not an integer
	 */
	this.assertInteger = function(obj_Tested){
		if(typeof(obj_Tested) != "number"){
			throw new icodeon.rte.RteError("Object is not a number data type: " + typeof(obj_Tested));
		}
		var int_Value = parseInt(obj_Tested);
		if(isNaN(int_Value)){
			throw new icodeon.rte.RteError("Object annot be parsed to an integert data type: " + typeof(obj_Tested));
		}
	};
	
	/**
	 * @throws icodeon.cocd.CocdError
	 */
	this.initializeCocd = function(){
		if(!this.obj_Cocd){
			this.obj_Cocd = new this.c.Cocd();
		}
	};
	
	/**
	 * 
	 */
	this.terminateCocd = function(){
		if(this.obj_Cocd){
			this.obj_Cocd = undefined;
		}
	};
	
	/**
	 * Converts an array of definitions into an Xpath
	 * for the cocd
	 * @param {Array} arr_Definitions
	 * @return Xpath 
	 * @type String
	 * @private
	 */
	var defintionsArrayToXPath = function(arr_Definitions){
		var int_Count = arr_Definitions.length;
		var str_XPath = "";
		for(var i=0; i<int_Count; i++){
			str_XPath += arr_Definitions[i].field.cocdName;
			if(i == int_Count-1){
				break;
			}
			str_XPath += "/"
		}
		return str_XPath;
	};
	
	/**
	 * Converts an array of CMI name elemenys into an array of definitions
	 * @param {Array} arr_CmiNames
	 * @return Array of icodeon.rte.Definition objects 
	 * @type Array
	 * @private
	 */
	this.cmiNameToDefinitionsArray = function(arr_CmiNames){

		var arr_Definitions = new Array(arr_CmiNames.length-1);
		for(var i=1; i<arr_CmiNames.length; i++){
			// need to manage numerical indices
			arr_Definitions[i-1] = this.definitions[arr_CmiNames[i]];
        	try{
        		this.assertNotNullOrUndefined(arr_Definitions[i-1]);
        	}
        	catch(obj_Error){
        		// Undefined Data Model Element (401)
        		throw new this.c.CocdError(401, obj_Error.message);
        	}
		}
		return arr_Definitions;
	};
	
	/**
	 * @param {String} str_CmiName
	 * @return The CMI value corresponding to the CMI data model element
	 * @type String
	 * @throws icodeon.cocd.CocdError
	 */
	this.getValueFromCocd = function(str_CmiName){
		
		var arr_CmiNames = str_CmiName.split(".");
		if(arr_CmiNames[0] != "cmi"){
			return this.EMPTY_STR;
		}
		
		var arr_Definitions = this.cmiNameToDefinitionsArray(arr_CmiNames);

		// Find the final element
		var obj_Definition = arr_Definitions[arr_Definitions.length - 1];
		
		// See if the final element is a data model key word
		var b_count = false;
		if(obj_Definition.field.keyword){
			switch(obj_Definition.field.cmiName){
				case "_version":
				if(arr_Definitions.length==1){
					return "1.0";
				}
				else{
				// Data Model Element Does Not Have Version (401)
				throw new this.c.CocdError(301, "The _version keyword was used incorrectly for: " + 
				arr_Definitions[arr_Definitions.length - 2].field.cmiName);
				}
				case "_children":
				obj_Definition = arr_Definitions[arr_Definitions.length - 2];
				return obj_Definition.getChildren();
				case "_count":
				obj_Definition = arr_Definitions[arr_Definitions.length - 2];
				 b_count = true;
				break;
				default:
				// Undefined Data Model Element (401)
				throw new this.c.CocdError(401, "Unrecongised CMI data model keyword:" + obj_Definition.field.cmiName);
			}
		}
		
		
        if(!obj_Definition.field.read && obj_Definition.field.write){
			// Data Model Element Is Write Only (405)
			throw new this.c.CocdError(405, "Cannot read from data model element:" + obj_Definition.field.cmiName);
        }
        
        // Now convert the array of definitions to an XPath
        var str_XPath = defintionsArrayToXPath(arr_Definitions);

        // For leaf, get the single node value
        if(obj_Definition.isLeaf()){
			var obj_CocdElement = this.obj_Cocd.getNode(str_XPath);
			var str_CocdValue = this.x.getElementText(obj_CocdElement);
			return obj_Definition.toCmiValue(str_CocdValue);
        }
        
        //b_Count
        //var arr_CocdElements = this.obj_Cocd.getNodes(str_XPath);
        //TODO
	};
	

	/**
	 * @param {String} str_CmiName
	 * @param {String} str_CmiValue
	 * @throws icodeon.cocd.CocdError
	 */
	this.setValueToCocd = function(str_CmiName, str_CmiValue){
		
		var arr_CmiNames = str_CmiName.split(".");
		if(arr_CmiNames[0] != "cmi"){
			return this.TRUE;
		}
		
		var arr_Definitions = this.cmiNameToDefinitionsArray(arr_CmiNames);

		// Find the final element
		var obj_Definition = arr_Definitions[arr_Definitions.length - 1];
        if(!obj_Definition.field.write && obj_Definition.field.read){
			// Data Model Element Is Read Only (404)
			throw new this.c.CocdError(404, "Cannot write to data model element:" + obj_Definition.field.cmiName);
        }
        
        // Now validate the the value to be set
		obj_Definition.validateCmiValue(str_CmiValue);
        
        // Now convert the array of definitions to an XPath
        var str_XPath = defintionsArrayToXPath(arr_Definitions);

        // For leaf, get the single node value
        if(obj_Definition.isLeaf()){
			var obj_CocdElement = this.obj_Cocd.getNode(str_XPath);
			var str_CocdValue = obj_Definition.toCocdValue(str_CmiValue);
			this.x.setElementText(obj_CocdElement, str_CocdValue);
			return this.TRUE;
        }
        
        //var arr_CocdElements = this.obj_Cocd.getNodes(str_XPath);
        //TODO
	};
	
	/**
	 * @throws icodeon.cocd.CocdError
	 */
	this.commitCocd = function(){
	};
	
	/**
	 * 
	 */
	this.getBaseLastError = function(){
		try{
			this.assertInteger(this.int_ErrorCode);
		}
		catch(obj_Error){
			// General Exception (101)
			this.int_ErrorCode = 101;
			this.str_ErrorDiagnostic = obj_Error.message;
		}

		return this.int_ErrorCode.toString();
	};
	
	/**
	 * 
	 */
	this.getBaseErrorString = function(str_ErrorCode){
		try{
			this.assertString(str_ErrorCode);
		}
		catch(obj_Error){
			// General Exception (101)
			this.int_ErrorCode = 101;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.errors["101"];
		}
		
		var int_Code = parseInt(str_ErrorCode);
		try{
			this.assertInteger(int_Code);
		}
		catch(obj_Error){
			// General Exception (101)
			this.int_ErrorCode = 101;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.errors["101"];
		}

		var str_Error = this.errors[str_ErrorCode];
		try{
			this.assertNotNullOrUndefined(str_Error);
		}
		catch(obj_Error){
			// General Exception (101)
			this.int_ErrorCode = 101;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.EMPTY_STR;
		}

		return str_Error;
	};
	
	/**
	 * 
	 */
	this.getBaseDiagnostic = function(str_Param){
		try{
			this.assertString(str_Param);
		}
		catch(obj_Error){
			this.str_ErrorDiagnostic = obj_Error.message;
		}

		var str_Diagnostic = this.str_ErrorDiagnostic;
		try{
			this.assertNotNullOrUndefined(str_Diagnostic);
		}
		catch(obj_Error){
			// No available diagnostic
			return this.EMPTY_STR;
		}

		return str_Diagnostic;
	};
	
	/**
	 * Overriden method inherited from Object
	 */
	this.toString = function(){
		var str_Msg = "Type: icodeon.rte.Adapter";
		return str_Msg;
	};
};

/**
 * Construct a SCORM 2004 Adapter. The instance should
 * always be referred to as window.API_1484_11
 * 
 * @class The class represents the SCORM 2004 Adapter
 * @extends icodeon.rte.Adapter
 * @base icodeon.rte.Adapter
 * @constructor
 * @return A new instance of a SCORM 2004 API Adapter
 */
icodeon.rte.Adapter2004 = function(){
	icodeon.rte.Adapter.call(this);
	
	this.errors["0"]= "No Error (0)";
	this.errors["101"]= "General Exception (101)";
	this.errors["102"]= "General Initialization Failure (102)";
	this.errors["103"]= "Already Initialized (103)";
	this.errors["104"]= "Content Instance Terminated (104)";
	this.errors["111"]= "General Termination Failure (111)";
	this.errors["112"]= "Termination Before Initialization (112)";
	this.errors["113"]= "Termination After Termination (113)";
	this.errors["122"]= "Retrieve Data Before Initialization (122)";
	this.errors["123"]= "Retrieve Data After Termination (123)";
	this.errors["132"]= "Store Data Before Initialization (132)";
	this.errors["133"]= "Store Data After Termination (133)";
	this.errors["142"]= "Commit Before Initialization (142)";
	this.errors["143"]= "Commit After Termination (143)";
	
	this.errors["201"]= "General Argument Error (201)";
	
	this.errors["301"]= "General Get Failure (301)";
	this.errors["351"]= "General Set Failure (351)";
	this.errors["391"]= "General Commit Failure (391)";
	
	this.errors["401"]= "Undefined Data Model Element (401)";
	this.errors["402"]= "Unimplemented Data Model Element (402)";
	this.errors["403"]= "Data Model Element Value Not Initialized (403)";
	this.errors["404"]= "Data Model Element Is Read Only (404)";
	this.errors["405"]= "Data Model Element Is Write Only (405)";
	this.errors["406"]= "Data Model Element Type Mismatch (406))";
	this.errors["407"]= "Data Model Element Value Out Of Range (407)";
	this.errors["408"]= "Data Model Dependency Not Established (408)";

	/**
	 * Session Method. The function is used to initiate the 
	 * communication session. It allows the LMS to handle 
	 * LMS specific initialization issues.
	 * 
	 * @param {String} str_Param An empty characterstring shall 
	 * be passed as a parameter.
	 * @return The function can return one of two values "true" or "false". 
	 * The return value shall berepresented as a characterstring.
	 * @type String
	 */
	this.Initialize = function(str_Param){
		try{
			this.assertEquals(this.EMPTY_STR,str_Param);
		}
		catch(obj_Error){
			// General Argument Error (201)
			this.int_ErrorCode = 201;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.FALSE;
		}
		
		if(this.b_Initalized){
			// Already Initialized (103)
			this.int_ErrorCode = 103;
			return this.FALSE;
		}
		if(this.b_Terminated){
			// Content Instance Terminated (104)
			this.int_ErrorCode = 104;
			return this.FALSE;
		}
		
		try{
			this.initializeCocd();
		}
		catch(obj_CocdError){
			if(obj_CocdError.getErrorCode){
				this.int_ErrorCode = obj_CocdError.getErrorCode();
			}
			else{
				// General Initialization Failure (102)
				this.int_ErrorCode = 102;
			}
			this.str_ErrorDiagnostic = obj_CocdError.message;
			return this.FALSE;
		}
		
		this.b_Initalized = true;
		this.b_Terminated = false;
		
		this.int_ErrorCode = 0;
		this.str_ErrorDiagnostic = undefined;
		
		return this.TRUE;
	};
	
	/**
	 * Session Method. The function is used to terminate 
	 * the communication session. It is used by the SCO when 
	 * the SCO has determined that it no longer needs to 
	 * communicate with the LMS.
	 * 
	 * @param {String} str_Param An empty characterstring shall 
	 * be passed as a parameter.
	 * @return The function can return one of two values "true" or "false". 
	 * The return value shall berepresented as a characterstring.
	 * @type String
	 */
	this.Terminate = function(str_Param){
		try{
			this.assertEquals(this.EMPTY_STR,str_Param);
		}
		catch(obj_Error){
			// General Argument Error (201)
			this.int_ErrorCode = 201;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.FALSE;
		}
		
		if(!this.b_Initalized){
			// Termination Before Initialization (112)
			this.int_ErrorCode = 112;
			return this.FALSE;
		}
		if(this.b_Terminated){
			// Termination After Termination (113)
			this.int_ErrorCode = 113;
			return this.FALSE;
		}
		
		try{
			var b_Result = this.Commit(this.EMPTY_STR);
			if(b_Result == this.FALSE){
				// General Termination Failure (111)
				this.int_ErrorCode = 111;
				return this.FALSE;
			}
		}
		catch(obj_Error){
			// General Termination Failure (111)
			this.int_ErrorCode = 111;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.FALSE;
		}
		
		this.terminateCocd();
		
		this.b_Initalized = false;
		this.b_Terminated = true;
		
		this.int_ErrorCode = 0;
		this.str_ErrorDiagnostic = undefined;
		
		return this.TRUE;
	};
	
	/**
	 * Data Transfer Method. The method requests forwarding to the 
	 * persistent data store any data from the SCO that may have been 
	 * cached by the API Instance since the last call to Initialize() 
	 * or Commit(), whichever occurred most recently.
	 * 
	 * @param {String} str_Param An empty characterstring shall 
	 * be passed as a parameter.
	 * @return The function can return one of two values "true" or "false". 
	 * The return value shall berepresented as a characterstring.
	 * @type String
	 */
	this.Commit = function(str_Param){
		try{
			this.assertEquals(this.EMPTY_STR,str_Param);
		}
		catch(obj_Error){
			// General Argument Error (201)
			this.int_ErrorCode = 201;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.FALSE;
		}
		
		if(!this.b_Initalized){
			// Commit Before Initialization (142)
			this.int_ErrorCode = 142;
			return this.FALSE;
		}
		if(this.b_Terminated){
			// Commit After Termination (143)
			this.int_ErrorCode = 143;
			return this.FALSE;
		}
		
		try{
			this.commitCocd();
		}
		catch(obj_CocdError){
			if(obj_CocdError.getErrorCode){
				this.int_ErrorCode = obj_CocdError.getErrorCode();
			}
			else{
				// General Commit Failure (391)
				this.int_ErrorCode = 391;
			}
			this.str_ErrorDiagnostic = obj_CocdError.message;
			return this.FALSE
		}
		
		this.int_ErrorCode = 0;
		this.str_ErrorDiagnostic = undefined;
		
		return this.TRUE;
	};
	
	/**
	 * Support Method. This method requests the error code 
	 * for the current error state of the API Instance. 
	 * If a SCO calls this method, the API Instance shall not 
	 * alter the current error state, but simply return the 
	 * requested information.
	 * 
	 * @return The API Instance shall return the error code 
	 * reflecting the current error state of the API Instance. 
	 * The return value shall be a characterstring (convertible 
	 * to an integer in the range from 0 to 65536 inclusive) 
	 * representing the error code of the last error encountered.
	 * @type String 
	 */
	this.GetLastError = function(){
		return this.getBaseLastError();
	};
	
	/**
	 * Support Method. This method requests the error code 
	 * for the current error state of the API Instance. 
	 * If a SCO calls this method, the API Instance shall not 
	 * alter the current error state, but simply return the 
	 * requested information.
	 * 
	 * @param {String} str_ErrorCode Represents the characterstring 
	 * of the error code (integer value) corresponding to an error message.
	 * @return If the requested error code is unknown by the LMS, 
	 * an empty characterstring shall be returned. This is the only 
	 * time that an empty characterstring shall be returned.
	 * @type String
	 */
	this.GetErrorString = function(str_ErrorCode){
		return this.getBaseErrorString(str_ErrorCode);
	};
	
	/**
	 * Support Method. The GetDiagnostic() function exists for 
	 * LMS specific use. It allows the LMS to define additional 
	 * diagnostic information through the API Instance. This call 
	 * has no effect on the current error state; it simply returns 
	 * the requested information.
	 * 
	 * @param {String} parameter: A value for diagnostics.
	 * @return The API Instance shall return a characterstring representing 
	 * the diagnostic information. The maximum length of the characterstring 
	 * returned shall be 255 characters. If the parameter is unknown by 
	 * the LMS, an empty characterstring shall be returned.
	 * @type String
	 */
	this.GetDiagnostic = function(str_Param){
		return this.getBaseDiagnostic(str_Param);
	};
	
	/**
	 * Data-Transfer Method. The function requests information from an LMS. 
	 * It permits the SCO to request information from the LMS.
	 * 
	 * @param {String} str_Param The parameter represents the 
	 * complete identification of a data model element.
	 * @return The method can return one of two values. The return 
	 * value shall be represented as a characterstring. (1) A characterstring 
	 * containing the value associated with the parameter, (2) If an error occurs, 
	 * then the API Instance shall set an error code to a value specific 
	 * to the error and return an empty characterstring. 
	 * @type String
	 */
	this.GetValue = function(str_Param){

		try{
			this.assertNotNullOrUndefined(str_Param);
			this.assertString(str_Param);
		}
		catch(obj_Error){
			// Undefined Data Model Element (401)
			this.int_ErrorCode = 401;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.EMPTY_STR;
		}
		
		if(!this.b_Initalized){
			// Retrieve Data Before Initialization (122)
			this.int_ErrorCode = 122;
			return this.EMPTY_STR;
		}
		
		if(this.b_Terminated){
			// Retrieve Data After Termination (123)
			this.int_ErrorCode = 123;
			return this.EMPTY_STR;
		}
		
		var str_ReturnValue = this.EMPTY_STR;
		try{
			//get the datamodel element
			str_ReturnValue = this.getValueFromCocd(str_Param);
		}
		catch(obj_CocdError){
			if(obj_CocdError.getErrorCode){
				this.int_ErrorCode = obj_CocdError.getErrorCode();
			}
			else{
				// General Get Failure (301)
				this.int_ErrorCode = 301;
			}
			this.str_ErrorDiagnostic = obj_CocdError.message;
			return this.EMPTY_STR;
		}
		
		this.int_ErrorCode = 0;
		this.str_ErrorDiagnostic = undefined;
		
		return str_ReturnValue;
	};
	
	/**
	 * Data-Transfer Method. This method allows the SCO to send 
	 * information to the LMS for storage.
	 * 
	 * @param {String} str_Param The parameter represents the 
	 * complete identification of a data model element.
	 * @param {String} str_Value Represents the 
	 * data model element value to be assigned.
	 * @return The return value shall be represented as a characterstring as either
	 * true of false
	 * @type String
	 */
	this.SetValue = function(str_Param, str_Value){

		try{
			this.assertNotNullOrUndefined(str_Param);
			this.assertString(str_Param);
		}
		catch(obj_Error){
			// Undefined Data Model Element (401)
			this.int_ErrorCode = 401;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.FALSE;
		}
		
		if(!this.b_Initalized){
			// Store Data Before Initialization (132)
			this.int_ErrorCode = 132;
			return this.FALSE;
		}
		
		if(this.b_Terminated){
			// Store Data After Termination (133)
			this.int_ErrorCode = 133;
			return this.FALSE;
		}
		
		try{
			this.assertNotNullOrUndefined(str_Value);
			this.assertString(str_Value);
		}
		catch(obj_Error){
			// Data Model Element Type Mismatch (406)
			this.int_ErrorCode = 406;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.FALSE;
		}
		

		try{
			//set the datamodel element
			this.setValueToCocd(str_Param, str_Value)
		}
		catch(obj_CocdError){
			if(obj_CocdError.getErrorCode){
				this.int_ErrorCode = obj_CocdError.getErrorCode();
			}
			else{
				// General Set Failure (351)
				this.int_ErrorCode = 351
			}
			this.str_ErrorDiagnostic = obj_CocdError.message;
			return this.FALSE
		}
		
		this.int_ErrorCode = 0;
		this.str_ErrorDiagnostic = undefined;
		
		return this.TRUE;
	};
	
	/**
	 * Overriden method inherited from Object
	 */
	this.toString = function(){
		var str_Msg = "Type: icodeon.rte.Adapter2004";
		return str_Msg;
	};
};

icodeon.rte.Adapter2004.prototype = new icodeon.rte.Adapter();
icodeon.rte.Adapter2004.prototype.constructor = icodeon.rte.Adapter2004;

/**
 * Construct a SCORM 1.2 Adapter. The instance should
 * always be referred to as window.API
 * 
 * @class The class represents the SCORM 1.2 Adapter
 * @extends icodeon.rte.Adapter
 * @base icodeon.rte.Adapter
 * @constructor
 * @return A new instance of a SCORM 1.2 API Adapter
 */
icodeon.rte.Adapter1p2 = function(){
	icodeon.rte.Adapter.call(this);
	
	this.errors["0"]= "No Error (0)";
	this.errors["101"]= "General Exception (101)";

	this.errors["201"]= "Invalid Argument (201)";
	this.errors["202"]= "Element Cannot Have Children (202)";
	this.errors["203"]= "Element Not An Array. Cannot Have Count (203)";
	
	this.errors["301"]= "Not Initialized (301)";

	this.errors["401"]= "Not Implemented Error (401)";
	this.errors["402"]= "Invalid Set Value. Element Is A Key Word (402)";
	this.errors["403"]= "Element Is Read Only (403)";
	this.errors["404"]= "Element Is Write Only (404)";
	this.errors["405"]= "Incorrect Data Type (405)";
	
    /**
     * Method to convert the SCORM 2004 data model error code
     * to a SCORM 1.2 equivalent.
     *
     * @private
	 * @param {Number} int_Code the SCORM 2004 error code
	 * @return The corresponding SCORM 1.2 error code
	 * @type Number
     */
    var convert2004Error = function(int_Code){
        switch(int_Code){
        
            case 404:return 403;
            case 405:return 404;
                
            default:return int_Code;;
        }
		return int_Code;
    };
	
    /**
     * Method to convert the SCORM 1.2 data model element name
     * to a SCORM 2004 and IEEE 1484.11.3 equivalent for reading
     * and writing to a document instance of IEEE 1484.11.3 valid
     * XML.
     *
     * @private
	 * @param {String} str_Param the SCORM 1.2 parameter name
	 * @return The corresponding SCORM 2004 parameter name
	 * @type String
     */
    var convert1p2Name = function(str_Param){
        switch(str_Param){
        
            case "cmi.core.credit":return "cmi.credit";
            case "cmi.core.entry":return "cmi.entry";
            case "cmi.core.exit":return "cmi.exit";
            case "cmi.core.lesson_mode":return "cmi.mode";
            case "cmi.core.score":return "cmi.score";
            case "cmi.core.score.raw":return "cmi.score.raw";
            case "cmi.core.score.min":return "cmi.score.min";
            case "cmi.core.score.max":return "cmi.score.max";
            case "cmi.core.score._children":return "cmi.score._children";

        
            default:return str_Param;
        }
		return str_Param;
    };
    
    /**
     * @private
	 * @param {String} str_Value the SCORM 1.2 parameter value
	 * @return The corresponding SCORM 2004 parameter nvalue
	 * @type String
     */
    var convert1p2Value = function(str_Value){
		return str_Value;
    };
	
	/**
	 * Execution State. The function is used to initiate the 
	 * communication session. It allows the LMS to handle 
	 * LMS specific initialization issues.
	 * 
	 * @param {String} str_Param An empty characterstring shall 
	 * be passed as a parameter.
	 * @return The function can return one of two values "true" or "false". 
	 * The return value shall berepresented as a characterstring.
	 * @type String
	 */
	this.LMSInitialize = function(str_Param){
		try{
			this.assertEquals(this.EMPTY_STR,str_Param);
		}
		catch(obj_Error){
			// Invalid Argument Error (201)
			this.int_ErrorCode = 201;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.FALSE;
		}
		
		if(this.b_Initalized){
			// General Exception (101)
			this.int_ErrorCode = 101;
			return this.FALSE;
		}
		if(this.b_Terminated){
			// General Exception (101)
			this.int_ErrorCode = 101;
			return this.FALSE;
		}
		
		try{
			this.initializeCocd();
		}
		catch(obj_CocdError){
			// 2004 General Initialization Failure (102)
			var int_Code = 102;
			if(obj_CocdError.getErrorCode){
				int_Code = obj_CocdError.getErrorCode();
			}
			this.int_ErrorCode = convert2004Error(int_Code);
			this.str_ErrorDiagnostic = obj_CocdError.message;
			return this.FALSE;
		}
		
		this.b_Initalized = true;
		this.b_Terminated = false;
		
		this.int_ErrorCode = 0;
		this.str_ErrorDiagnostic = undefined;
		
		return this.TRUE;
	};
	
	/**
	 * Execution State. The function is used to terminate 
	 * the communication session. It is used by the SCO when 
	 * the SCO has determined that it no longer needs to 
	 * communicate with the LMS.
	 * 
	 * @param {String} str_Param An empty characterstring shall 
	 * be passed as a parameter.
	 * @return The function can return one of two values "true" or "false". 
	 * The return value shall berepresented as a characterstring.
	 * @type String
	 */
	this.LMSFinish = function(str_Param){
		try{
			this.assertEquals(this.EMPTY_STR,str_Param);
		}
		catch(obj_Error){
			// Invalid Argument Error (201)
			this.int_ErrorCode = 201;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.FALSE;
		}
		
		if(!this.b_Initalized){
			// Not Initialized (301)
			this.int_ErrorCode = 301;
			return this.FALSE;
		}
		if(this.b_Terminated){
			// General Exception (101)
			this.int_ErrorCode = 101;
			return this.FALSE;
		}
		
		try{
			var b_Result = this.LMSCommit(this.EMPTY_STR);
			if(b_Result == this.FALSE){
				// General Exception (101)
				this.int_ErrorCode = 101;
				return this.FALSE;
			}
		}
		catch(obj_Error){
			// General Exception (101)
			this.int_ErrorCode = 101;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.FALSE;
		}
		
		try{
			this.terminateCocd();
		}
		catch(obj_CocdError){
			// 2004 General Termination Failure (111)
			var int_Code = 111;
			if(obj_CocdError.getErrorCode){
				int_Code = obj_CocdError.getErrorCode();
			}
			this.int_ErrorCode = convert2004Error(int_Code);
			this.str_ErrorDiagnostic = obj_CocdError.message;
			return this.FALSE;
		}
		
		this.b_Initalized = false;
		this.b_Terminated = true;
		
		this.int_ErrorCode = 0;
		this.str_ErrorDiagnostic = undefined;
		
		return this.TRUE;
	};
	
	/**
	 * Data Transfer Method. The method requests forwarding to the 
	 * persistent data store any data from the SCO that may have been 
	 * cached by the API Instance since the last call to Initialize() 
	 * or Commit(), whichever occurred most recently.
	 * 
	 * @param {String} str_Param An empty characterstring shall 
	 * be passed as a parameter.
	 * @return The function can return one of two values "true" or "false". 
	 * The return value shall berepresented as a characterstring.
	 * @type String
	 */
	this.LMSCommit = function(str_Param){
		try{
			this.assertEquals(this.EMPTY_STR,str_Param);
		}
		catch(obj_Error){
			// General Argument Error (201)
			this.int_ErrorCode = 201;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.FALSE;
		}
		
		if(!this.b_Initalized){
			// Not Initialized (301)
			this.int_ErrorCode = 301;
			return this.FALSE;
		}
		if(this.b_Terminated){
			// General Exception (101)
			this.int_ErrorCode = 101;
			return this.FALSE;
		}
		
		try{
			this.commitCocd();
		}
		catch(obj_CocdError){
			// General Commit Failure (391)
			var int_Code = 391;
			if(obj_CocdError.getErrorCode){
				int_Code = obj_CocdError.getErrorCode();
			}
			this.int_ErrorCode = convert2004Error(int_Code);
			this.str_ErrorDiagnostic = obj_CocdError.message;
			return this.FALSE
		}
		
		this.int_ErrorCode = 0;
		this.str_ErrorDiagnostic = undefined;
		
		return this.TRUE;
	};
	
	/**
	 * Data Transfer Method. The function requests information from an LMS. 
	 * It permits the SCO to request information from the LMS.
	 * 
	 * @param {String} str_Param The parameter represents the 
	 * complete identification of a data model element.
	 * @return The method can return one of two values. The return 
	 * value shall be represented as a characterstring. (1) A characterstring 
	 * containing the value associated with the parameter, (2) If an error occurs, 
	 * then the API Instance shall set an error code to a value specific 
	 * to the error and return an empty characterstring. 
	 * @type String
	 */
	this.LMSGetValue = function(str_Param){
		try{
			this.assertNotNullOrUndefined(str_Param);
			this.assertString(str_Param);
		}
		catch(obj_Error){
			// Not Implemented (401)
			this.int_ErrorCode = 401;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.EMPTY_STR;
		}
		
		if(!this.b_Initalized){
			// Not Initialized (301)
			this.int_ErrorCode = 301;
			return this.EMPTY_STR;
		}
		
		if(this.b_Terminated){
			// General Exception (101)
			this.int_ErrorCode = 101;
			return this.EMPTY_STR;
		}
		
		str_Param = convert1p2Name(str_Param);

		var str_ReturnValue = this.EMPTY_STR;
		try{
			//get the datamodel element
			str_ReturnValue = this.getValueFromCocd(str_Param);
		}
		catch(obj_CocdError){
			// 2004 General Get Failure (301)
			var int_Code = 301;
			if(obj_CocdError.getErrorCode){
				int_Code = obj_CocdError.getErrorCode();
			}
			this.int_ErrorCode = convert2004Error(int_Code);
			this.str_ErrorDiagnostic = obj_CocdError.message;
			return this.EMPTY_STR;
		}
		
		this.int_ErrorCode = 0;
		this.str_ErrorDiagnostic = undefined;
		
		return str_ReturnValue;
	};
	
	/**
	 * Data Transfer Method. This method allows the SCO to send 
	 * information to the LMS for storage.
	 * 
	 * @param {String} str_Param The parameter represents the 
	 * complete identification of a data model element.
	 * @param {String} str_Value Represents the 
	 * data model element value to be assigned.
	 * @return The return value shall be represented as a characterstring as either
	 * true of false
	 * @type String
	 */
	this.LMSSetValue = function(str_Param, str_Value){
		
		try{
			this.assertNotNullOrUndefined(str_Param);
			this.assertString(str_Param);
		}
		catch(obj_Error){
			// Not Implemented (401)
			this.int_ErrorCode = 401;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.FALSE;
		}
		
		if(!this.b_Initalized){
			// Not Initialized (301)
			this.int_ErrorCode = 301;
			return this.FALSE;
		}
		
		if(this.b_Terminated){
			// General Exception (101)
			this.int_ErrorCode = 101;
			return this.FALSE;
		}
		
		try{
			this.assertNotNullOrUndefined(str_Value);
			this.assertString(str_Value);
		}
		catch(obj_Error){
			// Incorrect data type (405)
			this.int_ErrorCode = 405;
			this.str_ErrorDiagnostic = obj_Error.message;
			return this.FALSE;
		}
		
		// set the datamodel element
		str_Param = convert1p2Name(str_Param);
		str_Value = convert1p2Value(str_Value);
		
		try{
			this.setValueToCocd(str_Param, str_Value);
		}
		catch(obj_CocdError){
			// 2004 General Set Failure (351)
			var int_Code = 351;
			if(obj_CocdError.getErrorCode){
				int_Code = obj_CocdError.getErrorCode();
			}
			this.int_ErrorCode = convert2004Error(int_Code);
			this.str_ErrorDiagnostic = obj_CocdError.message;
			return this.FALSE
		}
		
		this.int_ErrorCode = 0;
		this.str_ErrorDiagnostic = undefined;
		
		return this.TRUE;
		
	};
	
	/**
	 * State Management. This method requests the error code 
	 * for the current error state of the API Instance. 
	 * If a SCO calls this method, the API Instance shall not 
	 * alter the current error state, but simply return the 
	 * requested information.
	 * 
	 * @return The API Instance shall return the error code 
	 * reflecting the current error state of the API Instance. 
	 * The return value shall be a characterstring (convertible 
	 * to an integer in the range from 0 to 65536 inclusive) 
	 * representing the error code of the last error encountered.
	 * @type String 
	 */
	this.LMSGetLastError = function(){
		return this.getBaseLastError();
	};
	
	/**
	 * State Management. This method requests the error code 
	 * for the current error state of the API Instance. 
	 * If a SCO calls this method, the API Instance shall not 
	 * alter the current error state, but simply return the 
	 * requested information.
	 * 
	 * @param {String} str_ErrorCode Represents the characterstring 
	 * of the error code (integer value) corresponding to an error message.
	 * @return If the requested error code is unknown by the LMS, 
	 * an empty characterstring shall be returned. This is the only 
	 * time that an empty characterstring shall be returned.
	 * @type String
	 */
	this.LMSGetErrorString = function(str_ErrorCode){
		return this.getBaseErrorString(str_ErrorCode);
	};
	
	/**
	 * State Management. The LMSGetDiagnostic() function exists for 
	 * LMS specific use. It allows the LMS to define additional 
	 * diagnostic information through the API Instance. This call 
	 * has no effect on the current error state; it simply returns 
	 * the requested information.
	 * 
	 * @param {String} parameter: A value for diagnostics.
	 * @return The API Instance shall return a characterstring representing 
	 * the diagnostic information. The maximum length of the characterstring 
	 * returned shall be 255 characters. If the parameter is unknown by 
	 * the LMS, an empty characterstring shall be returned.
	 * @type String
	 */
	this.LMSGetDiagnostic = function(str_ErrorCode){
		return this.getBaseDiagnostic(str_ErrorCode);
	};
	
	/**
	 * Overriden method inherited from Object
	 */
	this.toString = function(){
		var str_Msg = "Type: icodeon.rte.Adapter1p2";
		return str_Msg;
	};
};

icodeon.rte.Adapter1p2.prototype = new icodeon.rte.Adapter();
icodeon.rte.Adapter1p2.prototype.constructor = icodeon.rte.Adapter1p2;
